//自定义持久层框架问题分析
//  1.Dao层使用自定义持久层框架，存在代码重复，整个操作的过程模版重复（加载配置文件、创建sqlSessionFactory、生产sqlSession）
//  2.statementId存在硬编码问题

//解决思路：使用代理模式生成Dao层接口的代理实现类

//package com.lagou.dao;
//
//import com.lagou.io.Resources;
//import com.lagou.pojo.User;
//import com.lagou.sqlSession.SqlSession;
//import com.lagou.sqlSession.SqlSessionFactory;
//import com.lagou.sqlSession.SqlSessionFactoryBuilder;
//
//import java.io.InputStream;
//import java.util.List;
//
//public class UserDaoImpl implements IUserDao {
//
//    @Override
//    public List<User> findAll() throws Exception {
//        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
//        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//
//        List<User> users = sqlSession.selectList("user.selectList");
//        users.forEach(user -> System.out.println(user));
//
//        return users;
//    }
//
//    @Override
//    public User findByCondition(User user) throws Exception {
//        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
//        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//
//        User user2 = sqlSession.selectOne("user.selectOne", user);
//        System.out.println(user2);
//
//        return user2;
//    }
//}
